----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/figure_01_market_share.log
  log type:  text
 opened on:  28 Oct 2022, 03:44:22

. *-------------------------------------------------------------------------------
. 
. 
. 
. *Figure 1: MNCs market share differences by income per capita of the location country (all economy)
. *-------------------------------------------------------
. clear all

. use "${data}/estimates_agg_naics_sales_s1_base_woparent.dta", clear

. 
. local grvar0 "gdp_pw_ppp" 

. local grvar1 "" 

. local rr ""

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was float, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)
(note: variable type was str5, now str9 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,985
        from master                         0  (_merge==1)
        from using                      2,985  (_merge==2)

    matched                                27  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(2,985 observations deleted)

. drop _merge

. 
. 
. gen mkt_share=exp(D_A)

. local LHS1 mkt_share

. local RHS ln_`grvar0'

. sum `LHS1' `RHS'  

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   mkt_share |         27    3.729584    2.920565   .6873776   11.51158
ln_gdp_pw_~p |         27   -.3431099    .2740156  -.9310113          0

. local xtitle "Relative output per worker"

. 
. reg `LHS1' `RHS'

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     10.63
       Model |  66.1455454         1  66.1455454   Prob > F        =    0.0032
    Residual |  155.626612        25  6.22506449   R-squared       =    0.2983
-------------+----------------------------------   Adj R-squared   =    0.2702
       Total |  221.772158        26  8.52969837   Root MSE        =     2.495

-------------------------------------------------------------------------------
    mkt_share |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
--------------+----------------------------------------------------------------
ln_gdp_pw_ppp |  -5.820876   1.785706    -3.26   0.003    -9.498607   -2.143146
        _cons |   1.732384   .7784287     2.23   0.035     .1291799    3.335588
-------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c1: display %-03.2fc round(b[1,1],0.01)

. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. 
. local xlab ""

. local xlab `xlab' -1.098622289 "1/3"

. local xlab `xlab' -0.693147289 "1/2"

. local xlab `xlab' -0.287672289 "2/3"

. local xlab `xlab' -0.000000000 "1"

. local xlab `xlab' 0.117802711 " "

. global opt1 msymbol(circle) mlabel(isocode) mlabcolor(blue) msize(small) mlabsize(small)

. 
. two (scatter `LHS1' `RHS', sort $opt1  mcolor(blue)), ysc(log) ylabel(0.01 1 2 4 8 16, format(%5.0f) labsize(medlarge)) xlabel(`xlab', format(%5.1f) labsize(medlarge)) ///
>         title("`title'", size(small))  ytitle("", size(medlarge)) xtitle("`xtitle'", size(medium)) graphregion(fcolor(white) lcolor(white)) legend(off) 

. 
. graph export "${rmain}/fig_01.pdf", replace
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/main/fig_01.pdf written in PDF format)

.         
. 
end of do-file

. do "C:\Users\VANESS~1\AppData\Local\Temp\STD2d9c_000000.tmp"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: figure_02_phi_vs_z.do
> Date: October 2022
> 
> Description: Reproduces Figure 2: Dev. accounting: firm-embedded productivity vs country-embedded factors.
> 
> *****************************************************************************************/
. 
. *-------------------------------------------------------------------------------
. global typeden=1

. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. global lf "LF"

. 
. *Log
. cap log close
